<?php

namespace app\index\traits;

use app\common\model\RankBroadcast;
use app\index\service\BroadcastService;

/**
 * 案源相关实时播报
 * Trait SourceBroadcastTrait
 * @package app\index\traits
 */
trait SourceBroadcastTrait
{

    /**
     * 添加实时播报
     * @param $lawyerId
     * @param $lawyerName
     * @param $sourceTypeName
     * @return void
     */
    private function addBroadcast($lawyerId, $lawyerName, $sourceTypeName): void
    {

        $message = [
            ['type' => 'text', 'red' => 102, 'text' => '刚刚抢单了' . $sourceTypeName . '案源'],
        ];

        $this->getBroadcastService()->addBroadcast(RankBroadcast::DONGTAI, $lawyerId, $lawyerName, $message);
    }

    private function getBroadcastService(): BroadcastService
    {
        return app(BroadcastService::class);
    }
}